use std::string::FromUtf8Error;

use reqwest::Error as ReqwestError;
use serde_json::Error as SerdeJsonError;

#[derive(Debug)]
pub enum CustomError {
    Reqwest(ReqwestError),
    SerdeJson(SerdeJsonError),
    IoError(std::io::Error),
    FromUtf8Error(FromUtf8Error),
}

impl From<ReqwestError> for CustomError {
    fn from(error: ReqwestError) -> Self {
        CustomError::Reqwest(error)
    }
}

impl From<std::io::Error> for CustomError {
    fn from(error: std::io::Error) -> Self {
        CustomError::IoError(error)
    }
}

impl From<SerdeJsonError> for CustomError {
    fn from(error: SerdeJsonError) -> Self {
        CustomError::SerdeJson(error)
    }
}

impl From<FromUtf8Error> for CustomError {
    fn from(error: FromUtf8Error) -> Self {
        CustomError::FromUtf8Error(error)
    }
}
